package cn.sciento.onelink.auth;

import cn.sciento.onelink.CommonResponse;
import cn.sciento.onelink.LinkRequest;
import cn.sciento.onelink.utils.TransIdUtil;
import lombok.Data;
import org.apache.http.client.methods.HttpRequestBase;

import java.util.HashMap;
import java.util.Map;

@Data
public class AuthRequest extends LinkRequest<CommonResponse<AuthResult>> {

    private String appId;

    private String password;

    public AuthRequest(String appId, String password) {
        super(Method.GET);
        this.appId = appId;
        this.password = password;

    }
    public HttpRequestBase generate() {
        this.path = "/ec/get/token";
        HashMap<String, Object> bodyMap = new HashMap<String, Object>();
        bodyMap.put("appid", appId);
        bodyMap.put("transid", TransIdUtil.generate(appId));
        bodyMap.put("password", password);
        this.setCompleteUrl(this.path, bodyMap);
        return httpRequestBase;
    }


}
